﻿using Base.Entities.Enums;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;

namespace System
{
    public static class MessageHelper
    {
        public const string Tips_Message = "Message";
        public const string Tips_AutoClose = "AutoClose";
        public const string Tips_AutoCloseTime = "AutoCloseTime";

        /// <summary>
        /// Tip弹窗
        /// </summary>
        public static void ShowTips(string message, bool autoClose = true, int time = 1000, Action<IDialogResult> callBack = null)
        {
            Dictionary<string, object> infos = new Dictionary<string, object>()
            {
                { Tips_Message,message},
                { Tips_AutoClose,autoClose},
                { Tips_AutoCloseTime,time},
            };

            ShowView(DialogTypeEnum.TipDialog.ToString(), infos, callBack);
        }

        /// <summary>
        /// 页面弹窗
        /// </summary>
        public static void ShowView(string viewName, Dictionary<string, object> infos = null, Action<IDialogResult> callBack = null)
        {
            var param = new DialogParameters();
            if (infos?.Any() == true)
            {
                param.FromParameters(infos);
            }
            GlobalManager.DialogService.ShowDialog(viewName, param, callBack ?? (result => { }));
        }
    }
}
